﻿using Furion.DatabaseAccessor;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;

namespace Furion.CMS.Domain
{
    /// <summary>
    /// 用户通行证限制
    /// </summary>
    [SuppressChangedListener]
    public class UserPassportRestrict : IEntity, IEntityTypeBuilder<UserPassportRestrict>
    {
        /// <summary>
        /// 用户通行证Id
        /// </summary>
        public int PassportId { get; set; }
        /// <summary>
        /// 用户通行证信息
        /// </summary>
        public virtual UserPassport Passport { get; set; }
        /// <summary>
        /// 白名单id
        /// </summary>
        public int WhitelistId { get; set; }
        /// <summary>
        /// 白名单信息
        /// </summary>
        public virtual Whitelist Whitelist { get; set; }

        public void Configure(EntityTypeBuilder<UserPassportRestrict> entityBuilder, DbContext dbContext, Type dbContextLocator)
        {
            entityBuilder.UseDefaultTableNameDefine();

            entityBuilder.HasIndex(k => new { k.PassportId, k.WhitelistId });
        }
    }
}
